package com.jfl.web.controller.system;

import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jfl.base.AbstractController;
import com.jfl.core.utils.ShiroUtils;
import com.jfl.model.SysMenu;
import com.jfl.model.SysUser;
import com.jfl.system.SysMenuService;

/**
 * Index
 *  
 * @author  赵炎
 * @version  [V1.00, 2018年12月3日]
 * @since V1.00
 */
@Controller
public class SysIndexController extends AbstractController
{
    /**
     * 版权年限
     */
    @Value("${jfl.copyrightYear}")
    private String copyrightYear;
    
    /**
     * 版本
     */
    @Value("${jfl.version}")
    private String version;
    
    @Value("${jfl.system.name}")
    private String systemName;
    
    @Reference(version="${jfl.version}")
    private SysMenuService sysMenuService;
   
    /** 
     * 系统首页
     * @param modelMap
     * @return
     */
    @GetMapping("/index")
    public String index(ModelMap modelMap)
    {
        // 取身份信息
        SysUser user = ShiroUtils.getCurrentUser();
        List<SysMenu> menus = sysMenuService.selectMenusByUserId(user.getId());
        modelMap.put("menus", menus);
        modelMap.put("user", user);
        modelMap.put("copyrightYear", copyrightYear);
        modelMap.put("systemName", systemName);
        return "index";
    }

    /** 
     * 系统介绍
     * @param modelMap
     * @return
     */
    @GetMapping("/system/main")
    public String main(ModelMap modelMap)
    {
        //TODO 后期添加图表数据
        modelMap.put("version", version);
        return "main";
    }
}
